<?php
include ('util/utf8.php');
include ('util/mysql.php');

$colum = getColunns ( 'cdcol', 'cds' );

$bbdd = conectarMySql ( 'cdcol', 'admin', 'admin', 'localhost' );

$consulta = 'select * from cds';
$resultado = $bbdd->query ( $consulta );

if (! $resultado) {
	print 'Error al ejecutar query';
} else {
	$tabla = "";
	$titulo = "<tr>\r\n";
	
	foreach ( $colum as $dato ) {
		$titulo .= "<th>$dato</th>\r\n";
	}
	$titulo .= "</tr>\r\n";
	
	foreach ( $resultado as $fila ) {
		$i = 0;
		$tabla .= "<tr>\r\n";
		foreach ( $fila as $valores ) {
			if ($i % 2 == 0) {
				$tabla .= "<td>$valores</td>\r\n";
			}
			$i ++;
		}
		$tabla .= "</tr>\r\n";
	}
	
}

?>

<!DOCTYPE html>
<html lang="es">
<head>
	<?php echo $meta; ?>
	<title>Prueba Conexión</title>
<style type="text/css">
table {
	text-align: center;
	margin-top: 50px;
}

td {
	padding: 10px;
}
</style>
</head>
<body>

	<table border='2' align='center'>
		<?php echo "$titulo $tabla"; ?>
	</table>

</body>
</html>